import Model.User;
import Tools.Yanzhengma;
import UserView.UserUi;
import fanshe6.JdbcTools;

import java.util.Scanner;

public class StudentRun {
    public static void main(String[] args) throws Exception {
            System.out.println("--------------------------------------");
            System.out.println("**欢迎使用学生信息管理系统***");
            System.out.println("--------------------------------------");
            for (int i = 0; i < 3; i++) {
                System.out.println("请输入管理员的账户和密码");
                Scanner scanner = new Scanner(System.in);
                System.out.println("账户：|");
                String zh = scanner.next();
                System.out.println("密码：|");
                String pw = scanner.next();
                String code = Yanzhengma.code();
                System.out.println("验证码是：(" + code + ")");
                String usercode = scanner.next();
                if (!usercode.equals(code)) {
                    System.out.println("验证码错误");
                } else {
                    User user = JdbcTools.queryBean("select * from user where sname=? and password=?", User.class, zh,pw);
                  if (user!=null){
                      System.out.println("登录成功！");
                      System.out.println("----请选择你的业务操作----");
                      //生成操作界面   用户表现层
                      UserUi userUi = new UserUi();
                      userUi.UI();
                  }else{
                      System.out.println("登录失败，账号或者密码输入错误");
                  }
                }
                if (i==2){
                    System.out.println("账户被锁定请联系相关人员，电话是：19234434652");
                }
            }
    }
}
